import request from '@/utils/request'
import { SkuInfoData, SkuResponseData } from './type'

enum API {
  // 获取已有的商品的数据-SKU
  SKU_URL = '/admin/product/list/',
  // 上架
  SALE_URL = '/admin/product/onSale/',
  // 下架
  OFFSALE_URL = '/admin/product/cancelSale/',
  // 获取商品详情接口
  SKUINFO_URL = '/admin/product/getSkuInfo/',
  // 删除已有的商品
  DELETESKU_URL = '/admin/product/deleteSku/',
}

// 获取已有的商品的数据-SKU
export const reqSkuList = (page: number, limit: number) => {
  return request.get<any, SkuResponseData>(API.SKU_URL + `${page}/${limit}`)
}
// 上架请求
export const reqSaleSku = (skuId: number) => {
  return request.get<any, any>(API.SALE_URL + skuId)
}
// 下架请求
export const reqOffSaleSku = (skuId: number) => {
  return request.get<any, any>(API.OFFSALE_URL + skuId)
}
// 获取商品详情接口
export const reqSkuInfo = (skuId: number) => {
  return request.get<any, SkuInfoData>(API.SKUINFO_URL + skuId)
}
// 删除已有的商品
export const reqRemoveSku = (skuId: number) => {
  return request.get<any, any>(API.DELETESKU_URL + skuId)
}
